package com.example.locat;

import com.example.locat.abs.Point;
import com.example.locat.abs.SignalNode;

import java.util.Random;

public class BeacoNode extends SignalNode {

    private String UUID;
    private int rssi;
    private int txPower;
    private String macAddress;

    public String getMacAddress() {
        return macAddress;
    }

    public void setMacAddress(String macAddress) {
        this.macAddress = macAddress;
    }

    @Override
    public String toString() {
        return "BeacoNode{" +
                "UUID='" + UUID + '\'' +
                ", rssi=" + rssi +
                ", txPower=" + txPower +
                ", point=" + point +
                ", major=" + major +
                ", minor=" + minor +
                ", distence=" + distence +
                '}';
    }

    public BeacoNode(){
        super();
    }



    public BeacoNode monitorData(Point point){
        String UUID = java.util.UUID.randomUUID().toString();
        int major = 10;
        int minor = 1;
        rssi = (new Random().nextInt() * 70 + 30) * -1;
        txPower = -60;
        distence =150;// new Random().nextInt(5) ;
        return new BeacoNode(point,UUID,major,minor,rssi,txPower,distence);
    }

    public BeacoNode(Point point, String UUID, int major, int minor, int rssi, int txPower, double distence) {
        super(point,major,minor,distence);
        this.UUID = UUID;
        this.rssi = rssi;
        this.txPower = txPower;
    }


    public String getUUID() {
        return UUID;
    }

    public void setUUID(String UUID) {
        this.UUID = UUID;
    }


    public int getRssi() {
        return rssi;
    }

    public void setRssi(int rssi) {
        this.rssi = rssi;
    }

    public int getTxPower() {
        return txPower;
    }

    public void setTxPower(int txPower) {
        this.txPower = txPower;
    }



/*
        return "BeacoNode{" +
                "UUID='" + UUID + '\'' +
                ", rssi=" + rssi +
                ", txPower=" + txPower +
                ", point=" + point +
                ", major=" + major +
                ", minor=" + minor +
                ", distence=" + distence +
                '}';

 */
    public static class Builder{
        private BeacoNode instance ;

        public Builder(){
            instance = new BeacoNode();
        }

        public Builder setTxPower(int txPower){
            instance.setTxPower(txPower);
            return this;
        }

        public Builder setRssi(int rssi){
            instance.setRssi(rssi);
            return this;
        }

        public Builder setPoint(int x, int y){
            instance.setPoint(new Point(x,y));
            return this;
        }

        public Builder setPoint(Point point){
            instance.setPoint(point);
            return this;
        }

        public Builder setMajor(int major){
            instance.setMajor(major);
            return this;
        }

        public Builder setMinor(int minor){
            instance.setMinor(minor);
            return this;
        }

        public Builder setDistance(double distance){
            instance.setDistence(distance);
            return this;
        }

        public BeacoNode build(){
            return instance;
        }

    public Builder setMacAddress(String macAddress) {
        instance.setMacAddress(macAddress);
        return this;
    }

    }

}
